const Order = require('../model/order.model.js');
class OrderService {
  async createOrder(order) {
    return await Order.create(order);
  }
  async findAllOrders(pageNum, pageSize, status) {
    const { rows, count } = await Order.findAndCountAll({
      attributes: ['goods_info', 'total', 'status', 'order_number'],
      where: {
        status: status
      },
      offset: pageSize * (pageNum - 1),
      limit: pageSize * 1,

    })
    return {
      pageNum,
      pageSize,
      total: count,
      list: rows
    }
  }
  async updateOrder(id, status) {
    return Order.update({ status: status }, { where: { id: id } })
  }
}

module.exports = new OrderService();